/**
 * user.js-
 */
import request from '../request'
class user {
  constructor() {
    this._defaultHeader = {
      'data-tupe': 'application/json'
    }
    this._request = new request
    this._request.setErrorHandler(this.errorHander)
  }

  /**
   * 统一的异常处理方法
   */
  errorHander(res) {
    console.error(res)
  }


  /**
   * 获取用户信息
   */
  getByUserId(data) {
    const app = getApp()
    return this._request.getRequest(app.globalData._baseUrl + 'sys/user/get-user-info', data).then(res => res.data)
  }


  getUserInfo(data) {
    const app = getApp()
    return this._request.getRequest(app.globalData._baseUrl + 'sys/user/get-info', data).then(res => res.data)
  }


  addAddress(data) {
    const app = getApp()
    return this._request.postRequest(app.globalData._baseUrl + 'sys/user/add-address', data).then(res => res.data)
  }

}
export default user